<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8" />
		<title>收银宝</title>
		<link rel="stylesheet" href="dist/css/layui.css" />
		<link rel="stylesheet" href="css/iconfont.css" />
		<link rel="stylesheet" href="css/shouy.css" />
	</head>

	<body>
		<div class="wrap">
			<div class="sy_header clearfix">
				<div class="sy_hleft">
					<div class="sy_logobox">
						<div class="sy_logo"><img src="img/logo-ma.png"></div>
						<p id="app_name"></p>
					</div>
					<ul class="sy_nav clearfix">
						<li class="active">
							<a href="index.html">
								<div class="iconfont icon-shouyintai"></div>
								<p>快速收银</p>
							</a>
						</li>
						<li>
							<a href="product_pay.html">
								<div class="iconfont icon-shangpinshouyin"></div>
								<p>商品收银</p>
							</a>
						</li>
						<li>
							<a href="house.html">
								<div class="iconfont icon-shangpinshouyin"></div>
								<p>房台收银</p>
							</a>
						</li>
						<li>
							<a href="xiaof_member.html">
								<div class="iconfont icon-weibiaoti-"></div>
								<p>我的会员</p>
							</a>
						</li>
						<li>
							<a href="jingybb.html">
								<div class="iconfont icon-jingyingbaobiao"></div>
								<p>经营报表</p>
							</a>
						</li>
					</ul>
				</div>
				<div class="sy_hright">
					<div class="sy_shopbox">
						<div class="sy_simg"><img id="toux" src="" style="background-color: #FFFFFF;"></div>
						<div class="sy_sinfo">
							<p class="sy_snam">店名：<span id="sname"></span></p>
							<p>用户：<span id="user"></span></p>
							<p class="exit" onclick="exit()">退出登陆</p>
						</div>
					</div>
				</div>
			</div>

			<div class="sy_conbox clearfix">
				<div class="sy_fleft">
					<div class="sy_flbox">
						<div class="sy_fnumbox">
							<div class="sy_fsrkbox clearfix">
								<div class="sy_fsrkl">消费总金额</div>
								<div class="sy_fsrkr"><input onkeyup="keyup(this)" type="text" id="price" name="price" placeholder="输入消费金额"></div>
							</div>
							<div class="sy_fyx">
								<span>现有鼓励金：<em id="my_score"></em></span>
								<span>&nbsp;&nbsp;鼓励金营销：</span>
								<span id="open_s"></span>
							</div>
						</div>
						<div class="sy_fbtnbox clearfix">
							<button type="button" onclick="sao_pay()" class="sy_fbtn orange">收款码</button>
							<button type="button" onclick="jiz_tck()" class="sy_fbtn blue">记账</button>
						</div>
					</div>
				</div>
				<div class="sy_fright">
					<div class="sy_frbox">
						<div class="sy_frbt">今日收银</div>
						<ul class="sy_frlist clearfix">
							<li>
								<p class="sy_frsybt">营业额</p>
								<p class="sy_frsybum"><em id="yye">0.00</em></p>
							</li>
							<li>
								<p class="sy_frsybt">鼓励金</p>
								<p class="sy_frsybum"><em id="glj">0.00</em></p>
							</li>
							<li>
								<p class="sy_frsybt">记账</p>
								<p class="sy_frsybum"><em id="jz">0.00</em></p>
							</li>
							<li>
								<p class="sy_frsybt">赠送</p>
								<p class="sy_frsybum"><em id="jz_zs">0.00</em></p>
							</li>
							<li>
								<p class="sy_frsybt">扫码</p>
								<p class="sy_frsybum"><em id="sm">0.00</em></p>
							</li>
							<li>
								<p class="sy_frsybt">抵扣</p>
								<p class="sy_frsybum"><em id="sm_dk">0.00</em></p>
							</li>
						</ul>
					</div>
				</div>
			</div>
			<div class="sy_bottom">服务热线：<em id="app_mobile"></em></div>
			<div id="errormsg" style="display: none;">
				<p class="bt">发现新版本：<em id="version">6.2</em></p>
				<p class="tip">优化界面，修复数据问题，增强稳定性。</p>
				<a class="btn" id="up_h" href="#">立即更新</a>
			</div>
		</div>
	</body>

</html>
<script type="text/javascript" src="dist/jquery-1.11.0.min.js"></script>
<script src="dist/json2.js"></script>
<script src="dist/layui.all.js"></script>
<script type="text/javascript" src="js/app.js"></script>
<script type="text/javascript" src="js/common.js"></script>
<script type="text/javascript">
	$(function() {
		set_info();
		var index = layer.load(1, {shade: [0.1, '#fff'] });
		$.ajax({
			url: APP.api_url + "Sy/get_agentinfo",
			data: {
				agent_id: getValue("agent_id"),
				app_id: APP.app_id,
				time: Date.parse(new Date())
			},
			success: function(data) {
				var res = data.data;
				var agent = res.agent;
				var is_score = agent['is_score'];
				var version = data.version;
				if(version != APP.version_name) {
					var href = APP.web_root + "setup.exe";
					$("#up_h").attr("href",href);
					$("#errormsg").show(300).delay(10000).hide(300); 
				}
				if(is_score == 1) {
					$("#open_s").text("启用");
				} else {
					$("#open_s").text("不启用");
				}
				$("#my_score").text((parseFloat(agent['score'])).toFixed(2));
				$("#yye").text((res['jz_total'] + res['sm_total']).toFixed(2));
				$("#glj").text((res['jz_score'] + res['sm_score']).toFixed(2));
				$("#jz").text(res['jz_total']);
				$("#jz_zs").text(res['jz_score']);
				$("#sm").text(res['sm_total']);
				$("#sm_dk").text(res['sm_score']);
				layer.close(index);
			}
		})
	})

	function sao_pay() {
		var price = parseFloat($("#price").val());
		if(price == "" || isNaN(price)) {
			layer.msg("请输入正确的账单金额!");
			return false;
		}
		$.ajax({
			url: APP.api_url + "Sy/get_sk",
			data: {
				agent_id: getValue("agent_id"),
				emp_id: getValue("id"),
				price: price,
				chain_id: getValue("chain_id"),
				type: 1,
				app_id: APP.app_id,
				time: Date.parse(new Date())
			},
			success: function(data) {
				topay_common(data,price,1);
				set_keyup(1);
			}
		})
	}
	function jiz_tck() {
		var price = parseFloat($("#price").val());
		if(price == "" || isNaN(price)) {
			layer.msg("请输入正确的账单金额!");
			return false;
		}
		var con = layer.confirm('确认操作?', function(index) {
			$.ajax({
				url: APP.api_url + "Sy/jizhang",
				data: {
					agent_id: getValue("agent_id"),
					emp_id: getValue("id"),
					price: price,
					oem_id: getValue("oem_id"),
					chain_id: getValue("chain_id"),
					app_id: APP.app_id,
					time: Date.parse(new Date())
				},
				success: function(data) {
					layer.close(con);
					jz_common(data,price,1);
				}
			})
		});
	}
</script>